<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Contract-add</title>
    <!-- 引入layui 样式-->
    <link rel="stylesheet" href="../../static/css/style.css"/>
    <link rel="stylesheet" href="../../static/layer/css/layui.css"/>
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
    <link rel="stylesheet" href="../../static/ucss/contract/loan.css"/>
    <style>
        .layui-form-label {
            width: 100px;
        }
    </style>
</head>

<body>
<form class="layui-form" id="contractForm_id">
    <div class="layui-tab layui-tab-brief" lay-filter="contractInfoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
            <li class="contractInfo">借款信息</li>
            <li class="contractInfo">财务信息</li>
            <li class="contractInfo">审批信息</li>
            <li class="contractInfo">审批流程</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="tab-body">
                    <div>
                        <div class="quote-submit-person">
                            <span>提交人： <span class="SUBMIT_PERSON_NAME"></span></span>
                        </div>
                        <div class="quote-tenant-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>借款方信息</span>
                            </div>
                            <div class="tenant-box suffix_class">

                                <div class="layui-form-item"  style="    margin-left: 18px;">
                                    <div class="layui-block">
                                        <label class="layui-form-label">出借方类型</label>
                                        <div class="layui-input-block">
                                            <input type="radio" name="LENDER" value="2" title="老客戶" checked lay-filter="radio_type">
                                            <input type="radio" name="LENDER" value="1" title="新客戶"  lay-filter="radio_type">

                                        </div>
                                    </div>

                                </div>

                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">出借方</label>
                                        <div class="layui-input-inline">
                                            <input type="radio" name="TRNANTRY" value="0" title="公司出借"
                                                   lay-filter="rent-type" checked="">
                                            <!--<input type="radio" name="TRNANTRY" value="1" title="个人出借"
                                                   lay-filter="rent-type">-->
                                        </div>
                                    </div>
                                    <!--<div class="layui-inline">
                                        <label class="layui-form-label">合同编号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="CONTRACT_NUM" id="contractNum" lay-verify="required" autocomplete="off"
                                                   class="layui-input required_fields">
                                        </div>
                                        <div class="layui-form-mid-red">*</div>
                                    </div>-->
                                    <div class="layui-inline class_select_company">
                                        <label class="layui-form-label">公司名</label>
                                        <div class="layui-input-inline">
                                            <select name="COMPANY" id="COMPANY" lay-verify="" lay-search="" lay-filter="company"  class="class_input_remove">
                                                <option value="">直接选择或搜索选择</option>
                                            </select>
                                        </div>
                                        <div class="layui-form-mid-red">*</div>
                                    </div>



                                    <div class="layui-inline  class_input_company"   style="display: none">
                                        <label class="layui-form-label">公司名</label>
                                        <div class="layui-input-inline">

                                            <input type="text" name="COMPANY" id="COMPANY_INPUT"  autocomplete="off"
                                                   class="layui-input  class_input_remove">

                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">成立日期</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input" id="ESTABLISH_DATE" name="ESTABLISH_DATE" placeholder="yyyy-MM-dd">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">统一社会信用码</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="BUSS_CODE" lay-verify="" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline person-input" style="display: none;">
                                        <label class="layui-form-label">姓名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="NAME" lay-verify="required" autocomplete="off"
                                                   class="layui-input required_fields">
                                        </div>
                                        <div class="layui-form-mid-red">*</div>
                                    </div>
                                    <!--<div class="layui-inline">
                                        <label class="layui-form-label">别名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="byname" lay-verify="required" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>-->
                                    <div class="layui-inline">
                                        <label class="layui-form-label ">行业类别</label>
                                        <div class="layui-input-inline">
                                            <select name="industry" lay-filter="industry">
                                                <option value=""></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label ">公司类型</label>
                                        <div class="layui-input-inline">
                                            <select name="COMPANY_TYPE">
                                                <option value="国有企业">国有企业</option>
                                                <option value="私营企业">私营企业</option>
                                                <option value="外商投资企业">外商投资企业</option>
                                                <option value="其他">其他</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline person-input" style="display: none;">
                                        <label class="layui-form-label">身份证号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="ID_CARD" lay-verify="" autocomplete="off"
                                                   class="layui-input required_fields">
                                        </div>
                                        <div class="layui-form-mid-red">*</div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">法定代表人</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="LEG_REN" lay-verify="" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="tel" name="LEG_TEL" lay-verify="" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">签订人</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="SIGN_REN" lay-verify="required" autocomplete="off"
                                                   class="layui-input ">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="tel" name="SIGN_TEL" lay-verify="required" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">注册资金(认缴)</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="REG_CAPITAL" lay-verify="required" autocomplete="off"
                                                   class="layui-input ">
                                        </div>
                                        <span class="input-label-unit">万元</span>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">注册资金(实缴)</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="REG_CAPITAL" lay-verify="required" autocomplete="off"
                                                   class="layui-input ">
                                            <span class="input-label-unit">万元</span>
                                        </div>
                                    </div>
                                </div>
                                <!--<div class="layui-form-item contact-person-arr">
                                </div>
                                <div class="tenant-add-person">
                                    <span onclick="operate.addContactPerson(this)">
                                        <i class="fa fa-plus-circle" aria-hidden="true"></i>
                                        <span>增加联系人</span>
                                    </span>
                                </div>-->
                                <!--<div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">通讯地址</label>
                                    <div class="layui-input-block">
                                        <textarea name="ADDRESS" placeholder="请输入通讯地址"
                                                  class="layui-textarea"></textarea>
                                    </div>
                                </div>-->
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">注册地址</label>
                                    <div class="layui-input-block">
                                        <textarea name="REG_ADDRESS" placeholder="请输入注册地址"
                                                  class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">经营地址</label>
                                    <div class="layui-input-block">
                                        <textarea name="BUSINESS_ADDRESS" placeholder="请输入经营地址"
                                                  class="layui-textarea"></textarea>
                                    </div>
                                </div>

                            </div>
                            <div class="quote-info">
                                <div class="quote-title">
                                    <i class="fa fa-circle-o" aria-hidden="true"></i>
                                    <span>附件</span>
                                </div>
                                <div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline layui-inline-normal attachments">
                                            <!--<div class="layui-input-inline">
                                                <span>1</span>
                                                <span>附件1</span>
                                                <span>下载</span>
                                            </div>-->
                                            <div class="layui-upload-list">
                                                <table class="layui-table">
                                                    <thead>
                                                    <tr>
                                                        <th>文件类型</th>
                                                        <th>文件名</th>
                                                        <th>大小</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="con_fujian_List"></tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <div class="quote-info">
                                <div class="quote-title">
                                    <i class="fa fa-circle-o" aria-hidden="true"></i>
                                    <span>其他信息</span>
                                    <div class="layui-input-block">
                                        <a class="layui-btn class_is_title"    onclick="toContractQtAdd(this)">点击录入</a>
                                    </div>
                                </div>

                            </div>



                        </div>
                    </div>
                </div>
            </div>
            <!--借款信息-->
            <div class="layui-tab-item">
                <div class="tab-body">
                    <div>
                        <div class="quote-contract-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>贷款信息</span>
                            </div>
                            <div class="contract-setting layui-row">
                                <div class="layui-col-md9">
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">借款金额：</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="LOAN_PRICE" lay-verify=""
                                                       autocomplete="off" value="0.00" placeholder="请输入借款金额"
                                                       class="layui-input">
                                                <span class="input-label-unit">元</span>
                                            </div>
                                            <!--<span class="input-label-unit">元/㎡·天</span>-->
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">借款利率：</label>
                                            <div class="layui-input-inline layui-input-longer">
                                                <input type="number" name="BORROW_INTEREST_RATE" lay-verify=""
                                                       autocomplete="off" class="layui-input">
                                                <span class="input-label-unit">%</span>
                                                <span class="input-label-mon">日利率</span>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">借款期限：</label>
                                            <div class="layui-input-inline layui-input-longer">
                                                <input type="number" name="BORROW_PERIOD" lay-verify=""
                                                       autocomplete="off" class="layui-input">
                                                <span class="input-label-unit">天</span>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">滞纳金利率：</label>
                                            <div class="layui-input-inline layui-input-longer">
                                                <input type="number" name="LATE_PAYMENT_RATE" lay-verify=""
                                                       autocomplete="off" class="layui-input">
                                                <span class="input-label-unit">%</span>
                                                <span class="input-label-mon">日利率</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- <div class="layui-col-md6 contract-setting-body contract-setting-center">
                                     <div class="layui-form-item">
                                         <div class="layui-inline">
                                             <label class="layui-form-label">合同签订日期：</label>
                                             <div class="layui-input-inline">
                                                 <input type="text" class="layui-input" id="contract-signing-date"
                                                        placeholder="yyyy-MM-dd">
                                                 <span class="input-label-unit-icon"><i class="fa fa-calendar"
                                                                                        aria-hidden="true"></i></span>
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">合同计租日期：</label>
                                             <div class="layui-input-inline">
                                                 <input type="text" class="layui-input" id="contract-rent-date"
                                                        placeholder="yyyy-MM-dd">
                                                 <span class="input-label-unit-icon"><i class="fa fa-calendar"
                                                                                        aria-hidden="true"></i></span>
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">合同结束日期：</label>
                                             <div class="layui-input-inline">
                                                 <input type="text" class="layui-input" id="contract-finish-date"
                                                        placeholder="yyyy-MM-dd">
                                                 <span class="input-label-unit-icon"><i class="fa fa-calendar"
                                                                                        aria-hidden="true"></i></span>
                                             </div>
                                         </div>
                                     </div>
                                     <div class="layui-btn-group">
                                         <a class="layui-btn layui-btn-primary layui-btn-small"
                                            onclick="operate.showDiscount(1);">一年</a>
                                         <a class="layui-btn layui-btn-primary layui-btn-small"
                                            onclick="operate.showDiscount(3);">三年</a>
                                         <a class="layui-btn layui-btn-primary layui-btn-small"
                                            onclick="operate.showDiscount(5);">五年</a>
                                     </div>
                                     <div style="margin-bottom: 10px"></div>
                                     <div class="layui-inline">
                                         <label class="layui-form-label">滞纳金比率：</label>
                                         <div class="layui-input-inline layui-input-extra-content" style=" height: 25px;">
                                             <select name="late_payment_rate" lay-filter="unit">
                                                 <option value="0">比率</option>
                                             </select>
                                         </div>
                                     </div>
                                     <div class="layui-inline">
                                         <label class="layui-form-label">剩余本金：</label>
                                         <div class="layui-input-inline layui-input-longer">
                                             &lt;!&ndash;<div class="layui-input-inline">&ndash;&gt;
                                             <input type="number" name="remaining_price" lay-verify=""
                                                    autocomplete="off" class="layui-input">
                                             <span class="input-label-unit">‰/天</span>
                                         </div>
                                     </div>
                                     <div class="layui-inline">
                                         <label class="layui-form-label">滞纳金执行日：</label>
                                         <div class="layui-input-inline layui-input-extra-content" style=" height: 25px;">
                                             <input type="number" name="late_pay_date" lay-verify=""
                                                    autocomplete="off" class="layui-input">
                                             <span class="input-label-unit">日</span>
                                             <span class="" style="position: absolute;top: 3px;right: -60px;z-index: 1;">收费日后</span>
                                         </div>
                                     </div>
                                 </div>-->
                                <div class="layui-clear"></div>
                            </div>
                            <div class="contract-setting layui-row">
                                <div class="layui-block contract-remark">
                                    <label class="layui-form-label" style="width: auto;">备注信息：</label>
                                    <div class="layui-input-block" style="margin-left: 80px;">
                                        <textarea name="remark" placeholder="请输入合同的备注信息"
                                                  class="layui-textarea"></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-clear"></div>
                        </div>
                        <div class="quote-rent-detail" style="display: none">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>借款明细</span>
                                <a onclick="operate.createRentDetail()"
                                   class="create-rent-detail-btn layui-btn layui-btn-primary layui-btn-small">
                                    <i class="fa fa-bar-chart" aria-hidden="true"></i>
                                    <span>生成借款明细</span>
                                </a>
                                <div class="layui-layer-content">Tips：合同信息修改后请点击左侧“生成借款明细”按钮重新生成借款信息。</div>
                                <a onclick="operate.editRentDetail()" class="layui-btn edit-rent-detail-btn">修改明细</a>
                                <div class="edit-rent-detail-btngroup">
                                    <a onclick="operate.cancelEditRentDetail()"
                                       class="layui-btn layui-btn-primary">取消</a>
                                    <a onclick="operate.saveEditRentDetail()" class="layui-btn">保存</a>
                                </div>
                            </div>
                            <div class="quote-rent-detail-list">
                                <ul class="container-rent-detail-list">
                                    <li>
                                        <div>
                                            <span>区间</span>
                                            <span></span>
                                        </div>
                                        <div>
                                            <span>付款日</span>
                                            <span></span>
                                        </div>
                                        <div>
                                            <span>滞纳金</span>
                                            <span class="label-unit-money">元/天</span>
                                        </div>
                                        <!--<div>
                                            <span>基础单价</span>
                                            <span class="label-unit-money">元/㎡·天</span>
                                        </div>-->
                                        <div>
                                            <span>最终金额</span>
                                            <span class="label-unit-money">元</span>
                                        </div>
                                        <!--<div>
                                            <span>备注</span>
                                        </div>-->
                                        <!--<div>
                                            <span>优惠</span>
                                            <span class="label-unit-money">元</span>
                                        </div>-->
                                    </li>
                                </ul>
                                <div class="no-data-tips">
                                    <span>暂无数据</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--财务信息-->
            <div class="layui-tab-item">
                <div class="tab-body">
                    <div>
                        <div class="quote-contract-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>数据日期</span>
                                <div class="" style="margin-left: 20px">
                                    <span type="text" id="DATA_START"></span>至
                                    <span type="text" id="DATA_END"></span>
                                </div>
                            </div>
                            <div class="layui-form">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="150">
                                        <col width="150">
                                        <col width="200">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th style="width: 30%;">名称</th>
                                        <th style="width: 40%;">计算公式</th>
                                        <th style="width: 30%;">比值率</th>
                                    </tr>
                                    </thead>
                                    <tbody class="tbody">
                                    <tr id="tab_jisuan">
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    资产负债率
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="">
                                                    负债总额\资产总额*100%
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <span type="number"  name="ASSET_LIABILITY" id="ASSET_LIABILITY" value="" style="text-align: right"></span>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr id="tab_jisuan">
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    流动比率
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="">
                                                    流动资产合计\流动负债合计*100%
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <span type="number"    name="LIQUIDITY" id="LIQUIDITY" value="" style="text-align: right"></span>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr id="tab_jisuan">
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    速动比率
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="">
                                                    （流动资产合计-存货）\流动负债合计*100%
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <span type="number"    name="QUICK_RATIO" id="QUICK_RATIO" value="" style="text-align: right"></span>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr id="tab_jisuan">
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    销售利润率
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="">
                                                    利润总额\营业收入*100%
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <span type="number"   name="PROFIT" id="PROFIT" value="" style="text-align: right"></span>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--审批信息-->
            <div class="layui-tab-item">
                <div class="tab-body">
                    <!--企业信息-->
                    <div class="quote-tenant-info">
                        <div class="quote-title">
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                            <span>借款企业信息</span>
                        </div>
                        <div class="tenant-box">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">行业预警</label>
                                    <div class="layui-input-inline">
                                        <select name="HYYJ" lay-filter="">
                                            <option value="支持行业">支持行业</option>
                                            <option value="维护行业">维护行业</option>
                                            <option value="高危行业">高危行业</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">社会主体评级</label>
                                    <div class="layui-input-inline">
                                        <select name="SHZTPJ" lay-filter="">
                                            <option value="无">无</option>
                                            <option value="A">A</option>
                                            <option value="AA">AA</option>
                                            <option value="AAA">AAA</option>
                                            <option value="B">B</option>
                                            <option value="BB">BB</option>
                                            <option value="BBB">BBB</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">税务评级</label>
                                    <div class="layui-input-inline">
                                        <select name="SWPJ" lay-filter="">
                                            <option value="A">A</option>
                                            <option value="B">B</option>
                                            <option value="C">C</option>
                                            <option value="D">D</option>
                                            <option value="M">M</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">企业风险</label>
                                    <div class="layui-input-inline">
                                        <select name="QYFX" lay-filter="">
                                            <option value="无提示风险">无提示风险</option>
                                            <option value="普通风险">普通风险</option>
                                            <option value="警示风险">警示风险</option>
                                            <option value="严重风险">严重风险</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">企业状态</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="QYZT" value="0" title="正常"
                                               lay-filter="" checked="">
                                        <input type="radio" name="QYZT" value="1" title="异常"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">欠税情况</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="QSQK" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="QSQK" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">欠缴社保</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="QJSB" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="QJSB" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">行政处罚记录</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="XZCFJL" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="XZCFJL" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">法院诉讼信息</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="FYSSXX" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="FYSSXX" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">法院强制执行</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="FYQZZX" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="FYQZZX" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">对外担保</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="DWDB" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="DWDB" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">对外担保不良</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="DWDBBL" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="DWDBBL" value="1" title="有"
                                               lay-filter="">
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">逾期贷款</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="YQDK" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="YQDK" value="1" title="有"
                                               lay-filter="" >
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">他行逾期贷款</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="THYQDK" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="THYQDK" value="1" title="有"
                                               lay-filter="">
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">抵押物权属清晰</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="DYWQSQX" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="DYWQSQX" value="1" title="有"
                                               lay-filter="">
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">关联企业不良</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="GLQYBL" value="0" title="无"
                                               lay-filter="" checked="">
                                        <input type="radio" name="GLQYBL" value="1" title="有"
                                               lay-filter="">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--审批信息-->
                    <div class="quote-contract-info">
                        <div class="quote-title">
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                            <span>审批内容</span>
                        </div>
                        <div class="contract-setting layui-row">
                            <div class="layui-block contract-remark">
                                <!--复审div-->
                                <div class="fushenDIV" style="display: none">
                                    <label class="layui-form-label" style="width: auto;">约访客户：</label>
                                    <div class="layui-input-block" style="margin-left: 80px;">
                                        <div class="layui-input-inline">
                                            <input type="radio" name="VISIT_CUSTOMER" value="0" title="约谈"
                                                   lay-filter="rent-type" checked="">
                                            <input type="radio" name="VISIT_CUSTOMER" value="1" title="下户"
                                                   lay-filter="rent-type">
                                        </div>
                                    </div>
                                </div>
                                <!--合规div-->
                                <div class="heguiDIV" style="display: none">
                                    <label class="layui-form-label" style="width: auto;">抵押物核对：</label>
                                    <div class="layui-input-block" style="margin-left: 80px;">
                                        <div class="layui-input-inline">
                                            <input type="radio" name="PAWN_FLAG" value="0" title="有误"
                                                   lay-filter="rent-type" checked="">
                                            <input type="radio" name="PAWN_FLAG" value="1" title="无误"
                                                   lay-filter="rent-type">
                                        </div>
                                    </div>
                                </div>
                                <label class="layui-form-label" style="width: auto;">审批意见：</label>
                                <div class="layui-input-block" style="margin-left: 80px;">
                                    <textarea name="DETAILS" placeholder="请输入审批意见" class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--房屋图片-->
                    <div class="quote-other-info">
                        <div class="quote-title">
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                            <span class="ATTname">房屋图片</span>
                        </div>
                        <div class="other-info-box">
                            <div class="attachment-info-box">
                                <!--<div class="attachment-administer">
                                <span>
                                    <i class="fa fa-cloud-upload" aria-hidden="true"></i>
                                    <span id="upload">上传附件</span>
                                    <div class="layui-upload-list" id="imgList"></div>
                                </span>
                                </div>-->
                                <div class="layui-upload">
                                    <div class="layui-upload-list">
                                        <table class="layui-table">
                                            <thead>
                                            <tr>
                                                <!--<th>缩略图</th>-->
                                                <th>文件名</th>
                                                <th>大小</th>
                                                <th>状态</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody id="demoList"></tbody>
                                        </table>
                                    </div>
                                    <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件
                                    </button>&nbsp;<button type="button" class="layui-btn" id="testListAction">开始上传</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--征信-->
                    <div class="quote-contract-info zxlj">
                        <div class="quote-title">
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                            <span>征信链接</span>
                        </div>
                        <div class="contract-setting layui-row">
                            <div class="layui-block">
                                <div class="" style="margin-left: 20px;display: inline">
                                   <a href="http://www.tjcredit.gov.cn/gsxt/" target="_blank" title="天津市市场主体信用信息公示系统"> 天津市市场主体信用信息公示系统</a>
                                </div>
                                <div class="" style="margin-left: 80px;display: inline">
                                    <a href="http://shixin.court.gov.cn/index.html" target="_blank" title="全国法院失信被执行人名单信息公布与查询  ">全国法院失信被执行人名单信息公布与查询  </a>
                                </div>
                                <div class="" style="margin-left: 80px;display: inline">
                                    <a href="http://www.tjsat.gov.cn/" target="_blank" title="国家税务总局天津市税务局">国家税务总局天津市税务局</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--审批流程-->
            <div class="layui-tab-item">
                <div class="tab-body">
                    <div class="quote-contract-info">
                        <div class="quote-title">
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                            <span>操作记录</span>
                        </div>
                        <div class="contract-setting layui-row">
                            <table id="historySH" lay-filter="zancunf"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <blockquote class="blockquote-bottom">
        <div class="blockquote-bottom-item">
            <a class="layui-btn layui-btn-small layui-btn-normal layui-btn-danger" onclick="operate.submit(this,1);">驳回</a>
            <a class="layui-btn layui-btn-small layui-btn-normal temporaryStorageBtn" onclick="operate.submit(this,0);">通过</a>
            <a class="layui-btn layui-btn-primary layui-btn-small cancelBtn" onclick="operate.cancel();">取消</a>

            <!--<a class="layui-btn layui-btn-small layui-btn-disabled submitBtn" onclick="operate.submit(this, 0);">提交</a>-->
        </div>
    </blockquote>
    <!--隐藏域-->
    <input type="hidden" name="DY_CHECK"  autocomplete="off"
           class="layui-input">
    <input type="hidden" name="DY_CHECK_NAME"  autocomplete="off"
           class="layui-input">
    <input type="hidden" name="PERSON_ID"  autocomplete="off"
           class="layui-input">
</form>
<script type="text/javascript" src="../../static/layer/layui.js"></script>
<script type="text/javascript" src="../../static/js/common/dateUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/typeUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/queryUtils.js"></script>
<script type="text/javascript" src="../../static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../../static/js/common/imgVideo.js"></script>
<!--操作记录图片-->
<script type="text/html" id="record_img">
    {{#  if(d.PATH!=undefined){  }}
    {{#  var yourString=d.PATH;  }}
    {{#  var result=yourString.split(",");  }}
    {{#  for(var i of result){  }}
    <span><a href="{{i}}" target="_blank" class="layui-btn layui-btn-mini layui-btn-normal">下载</a></span>
    {{# }  }}
    {{# }  }}
</script>
<!--操作详情-->
<script type="text/html" id="DETAILS">
    <span>
        {{#  if(d.VISIT_CUSTOMER!=undefined){ }}
        {{ d.VISIT_CUSTOMER }},
        {{#  } else { }}
        {{#  } }}
        {{ d.DETAILS }}
    </span>
</script>
<script>
    var $, element, layer, laydate, form;
    var tips = false;   // 合同信息生成明细修改提示状态
    var ftype = 1;  // 支付按月还是按日 0按日 1按月
    var today = DateUtils.dateFormat(new Date(), "yyyy-MM-dd"); // 今天的日期
    var LOAN_ID = QueryUtils.GetQueryString("LOAN_ID");//获取审核的合同id
    var CHECK_STATE = QueryUtils.GetQueryString("CHECK_STATE");//账单的状态
    var uploadfiles = new Array(); // 要上传的文件列表路径
    var IS_TITLE = QueryUtils.GetQueryString("IS_TITLE");
    layui.use(['jquery', 'element', 'layer', 'laydate', 'form', 'upload', 'table'], function () {
        // 加载元素控件
        $ = layui.jquery, element = layui.element, layer = layui.layer, laydate = layui.laydate, form = layui.form, table = layui.table;
        var upload = layui.upload;
        //初始化 审批页面
        $(".contractInfo").each(function () {
            if ("审批信息" == $(this).text()) {
                $(this).click();
            }
        });
        if(IS_TITLE=="show"){
            $(".class_is_title").html("查看详情");
        }
        //成立日期
        laydate.render({
            elem: '#ESTABLISH_DATE'
        });
        form.on('radio(radio_type)', function(data){

            var $classInputRemove = $(".class_input_remove");
            $classInputRemove.each(function(index ,val){
                $(val).val("");
            });
            radioType(data.value);
        });

        //下拉拦截
        form.on('select(company)', function(data){
            debugger

            var lenderval = $("input[name='LENDER']:checked").val();
            if(lenderval==2){
                var company = $("select[name='COMPANY']").val();
//是否回显
                isShowCompany(company);


            }
            console.log(data);
        });
        // 租赁方式单选框点击事件
        form.on('radio(rent-type)', function (data) {
            if (data.value == "0") {
                $(".person-input").hide();
                $(".company-input").show();
            } else if (data.value == "1") {
                $(".company-input").hide();
                $(".person-input").show();
            }
        });
        //多文件列表示例
        var files;
        var demoListView = $('#demoList')
            , uploadListIns = upload.render({
            elem: '#testList'
            , url: '/servlet/UploadHandleServlet'
            ,accept: 'file'
            , multiple: true
            , auto: false
            , bindAction: '#testListAction'
            , choose: function (obj) {
                files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function (index, file, result) {
                    var tr = $(['<tr id="upload-' + index + '">'
                        // , '<td><img src="' + result + '" alt="' + file.name + '" class="layui-upload-img"></td>'
                        , '<td>' + file.name + '</td>'
                        , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                        , '<td>等待上传</td>'
                        , '<td>'
                        , '<a onclick=\'operate.deleteImg(this, "' + file.ID + '");\' class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</a>'
                        , '</td>'
                        , '</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function () {
                        obj.upload(index, file);
                        return false;
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function () {
                        delete files[index]; //删除对应的文件
                        tr.remove();
                    });

                    demoListView.append(tr);
                });
            }
            , done: function (res, index, upload) {
                if (res.errcode == 0) { //上传成功
                    var obj = {};
                    obj.name = res.data.fileName;
                    obj.size = res.data.fileSize;
                    obj.ext = res.data.extName;
                    obj.url = res.data.fileUrl;
                    uploadfiles.push(obj);
                    var tr = demoListView.find('tr#upload-' + index)
                        , tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html(''); //清空操作
                    delete files[index]; //删除文件队列已经上传成功的文件
                    return;
                }
                this.error(index, upload);
            }
            , error: function (index, upload) {
                var tr = demoListView.find('tr#upload-' + index)
                    , tds = tr.children();
                tds.eq(3).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(4).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
        init.initcompanyList();
        init.initUser();
        init.initContractDate(today, today, today);
        init.initIndustry();//初始所属行业
        init.initContract();//初始化内容
        init.initrecord();//加载操作记录
        init.initDom();//加载审批不同的dom

    });
    //初始化方法
    var init = {
        //初始化公司信息
        initcompanyList:function(){
            $.ajax({
                url: "/financial/BorrowerListPD",
                data: {},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        for (var i = 0; i < res.data.length; i++) {
                            $("#COMPANY").append("<option value=" + res.data[i].COMPANY_NAME + ">" + res.data[i].COMPANY_NAME + "</option>");
                        }
                        form.render();
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        //获取审批过来的状态 来修改审批页的内容
        initDom:function(){
          switch (CHECK_STATE) {
              case "初审阶段":
                  $(".quote-other-info").hide();
                  break;
              case "复审阶段":
                  $(".fushenDIV").show();
                  $(".zxlj").hide();//征信链接
                  break;
              case "终审阶段":
                  $(".quote-other-info").hide();
                  $(".zxlj").hide();
                  break;
              case "合规阶段":
                  $(".heguiDIV").show();
                  $(".ATTname").html("抵押物图片");
                  $(".temporaryStorageBtn").html("通过并生成合同");
                  $(".zxlj").hide();
                  break;
          }
        },
        //初始化合同信息
        initContract: function () {
            $.ajax({
                url: "/LoanController/info",
                data: {ID: LOAN_ID},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        init.initSetValue(res.data);
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        // 初始化暂存合同信息赋值
        initSetValue: function (data) {
            // console.log(JSON.stringify(data));

            // 初始化租户
            var contract = data.contract;
            $("input[name='PERSON_ID']").val(contract.PERSON_ID);
            if (contract.TRNANTRY == 0) {
                console.log(contract.COMPANY_NAME)
                $("select[name='COMPANY']").val(contract.COMPANY_NAME);
                $("input[name='BUSS_CODE']").val(contract.BUSINESS_LICENSE);

                radioType(contract.LENDER);
                if(contract.LENDER==1){
                    $("#COMPANY_INPUT").val(contract.COMPANY_NAME);
                    $("input:radio[name='LENDER'][value='1']").attr('checked', 'true');
                }else{
                    $("select[name='COMPANY']").val(contract.COMPANY_NAME);
                    $("input:radio[name='LENDER'][value='2']").attr('checked', 'true');
                }


                $("input[name='LEG_REN']").val(contract.LEGAL_PERSON_NAME);
                $("input[name='LEG_TEL']").val(contract.LEGAL_PERSON_TEL);
            } else if (contract.TRNANTRY == 1) {
                $("input:radio[name='TRNANTRY'][value='0']").attr('checked', 'false');
                $("input:radio[name='TRNANTRY'][value='1']").attr('checked', 'true');
                $(".company-input").hide();
                $(".person-input").show();
                $("input[name='NAME']").val(contract.COMPANY_NAME);
                $("input[name='ID_CARD']").val(contract.BUSINESS_LICENSE);
            }
            $("input[name='CONTRACT_NUM']").val(contract.CONTRACT_NUM);
            $("input[name='byname']").val(contract.BYNAME);
            $("select[name='industry']").val(contract.INDUSTRY_ID);
            $("input[name='SIGN_REN']").val(contract.SIGNER);
            $("input[name='SIGN_TEL']").val(contract.SIGNER_TEL);
            $("textarea[name='ADDRESS']").val(contract.CONTRACT_ADDRESS);
            $("input[name='DY_CHECK']").val(contract.DY_CHECK);//动态审核字段
            $("input[name='DY_CHECK_NAME']").val(contract.DY_CHECK_NAME);//动态审核人的信息
            $("select[name='COMPANY_TYPE']").val(contract.COMPANY_TYPE);//公司类型
            $("input[name='REG_CAPITAL']").val(contract.REG_CAPITAL);
            $("input[name='REG_CAPITAL_PAY']").val(contract.REG_CAPITAL_PAY);
            $("input[name='ESTABLISH_DATE']").val(contract.ESTABLISH_DATE);//成立日期
            $("textarea[name='REG_ADDRESS']").val(contract.REG_ADDRESS);//注册地址
            $("textarea[name='BUSINESS_ADDRESS']").val(contract.BUSINESS_ADDRESS);//经营地址
            $(".SUBMIT_PERSON_NAME").html(contract.SUBMIT_PERSON_NAME);//提交人

            // 初始化联系人
            var contacts = data.contact;
            if (!!contacts) {
                for (var i = 0; i < contacts.length; i++) {
                    var contact = contacts[contacts.length - i - 1];
                    $(".tenant-add-person span:first").click();
                    $("input[name='lxr-name']").eq(i).val(contact.CONTACTS_NAME);
                    $("input[name='lxr-tel']").eq(i).val(contact.CONTACTS_TEL);
                }
            }

            // 初始化附件
            var attachments = data.attachment;
            if (!!attachments) {
                var host = location.host;
                for (var i = 0; i < attachments.length; i++) {
                    var attachment = attachments[i];
                    if(attachment.TYPE==="1"){
                        var demoListView = $('#con_fujian_List');
                        var tr = $(['<tr id="upload-' + (i + 1) + '">'
                            // , '<td><img src="http://' + host + '/' + attachment.PATH + '" alt="' + attachment.NAME + '" class="layui-upload-img"></td>'
                            , '<td>营业执照</td>'
                            , '<td>' + attachment.NAME + '</td>'
                            , '<td>' + (attachment.SIZE / 1014).toFixed(1) + 'kb</td>'
                            // , '<td><span style="color: #5FB878;">上传成功</span></td>'
                            , '<td>'
                            , '<a href="http://' + window.location.host + '/' + attachment.PATH + '" target="_blank" class=\"layui-btn layui-btn-mini layui-btn-normal\">下载</a>'
                            , '</td>'
                            , '</tr>'].join(''));
                        demoListView.append(tr);
                    }else if(attachment.TYPE==="4"){
                        var demoListView = $('#con_fujian_List');
                        var tr = $(['<tr id="upload-' + (i + 1) + '">'
                            // , '<td><img src="http://' + host + '/' + attachment.PATH + '" alt="' + attachment.NAME + '" class="layui-upload-img"></td>'
                            , '<td>财务附件</td>'
                            , '<td>' + attachment.NAME + '</td>'
                            , '<td>' + (attachment.SIZE / 1014).toFixed(1) + 'kb</td>'
                            // , '<td><span style="color: #5FB878;">上传成功</span></td>'
                            , '<td>'
                            , '<a href="http://' + window.location.host + '/' + attachment.PATH + '" target="_blank" class=\"layui-btn layui-btn-mini layui-btn-normal\">下载</a>'
                            , '</td>'
                            , '</tr>'].join(''));
                        demoListView.append(tr);
                    }

                }
            }
           // let  LOAN_PRICE=QueryUtils.fixedThousand(parseInt(contract.LOAN_PRICE),2)


            // 初始化合同基础信息和备注
            $("input[name='LOAN_PRICE']").val(contract.LOAN_PRICE);//借款金额
            $("input[name='BORROW_INTEREST_RATE']").val(contract.BORROW_INTEREST_RATE);//借款利率
            $("input[name='BORROW_PERIOD']").val(contract.BORROW_PERIOD);//借款利率
            $("input[name='LATE_PAYMENT_RATE']").val(contract.LATE_PAYMENT_RATE);//滞纳金比率
            // 合同备注
            $("textarea[name='remark']").val(contract.INFO);

            //初始化贷款信息
            var tb_financial = data.tb_financial;
            if(!!tb_financial){
                tb_financial.ASSET_LIABILITY&&$("#ASSET_LIABILITY").html(tb_financial.ASSET_LIABILITY+"%"); //资产负债率
                tb_financial.LIQUIDITY&&$("#LIQUIDITY").html(tb_financial.LIQUIDITY+"%"); //流动比率
                tb_financial.QUICK_RATIO&&$("#QUICK_RATIO").html(tb_financial.QUICK_RATIO+"%");  //速动比率
                tb_financial.PROFIT&&$("#PROFIT").html(tb_financial.PROFIT+"%");//销售利润率
                tb_financial.DATA_START&&$("#DATA_START").html(tb_financial.DATA_START.substring(0,7));//销售利润率
                tb_financial.DATA_END&&$("#DATA_END").html(tb_financial.DATA_END.substring(0,7));//销售利润率
            }

            //初始化借款企业信息
            let tb_loan_company=data.tb_loan_company;
            if(!!tb_loan_company){
                for(let i in tb_loan_company){
                    init.initCompanyValue(i,tb_loan_company[i]);
                }
                $("select[name='HYYJ']").val(tb_loan_company.HYYJ).attr("disabled","disabled" );
                $("select[name='SHZTPJ']").val(tb_loan_company.SHZTPJ).attr("disabled","disabled" );
                $("select[name='SWPJ']").val(tb_loan_company.SWPJ).attr("disabled","disabled" );
                $("select[name='QYFX']").val(tb_loan_company.QYFX).attr("disabled","disabled" );
            }
            form.render();
        },
        //借款企业信息复制
        initCompanyValue: function (radioName, radioValue) {
            var ro = document.getElementsByName(radioName);
            for (var i = 0; i < ro.length; i++) {
                if (ro[i].value == radioValue) {
                    ro[i].checked = true;
                    break;
                }
            }
            $("input[name=" + radioName + "]").each(function () {
                $(this).attr("disabled", true);
            })
        },
        // 初始化当前登录用户
        initUser: function () {
            $.ajax({
                url: "/happuser/userInfo",
                data: {},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        $(".user_name").html(res.data.name);
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        // 初始化合同签订日期、计租日期、结束日期
        initContractDate: function (aDate, bDate, cDate) {
            // 初始化合同签订日期
            laydate.render({
                elem: '#contract-signing-date',
                btns: ['now'],   // 只显示今天按钮
                done: function (value, date, endDate) {
                    operate.changeDate('signing', value);
                }
            });
            // 给合同签订日期设置初始值为今天
            $("#contract-signing-date").val(aDate);    // 日期工具类格式化日期
            // 初始化合同计租日期
            laydate.render({
                elem: '#contract-rent-date',
                btns: ['now'],   // 只显示今天按钮
                done: function (value, date, endDate) {
                    operate.changeDate('start', value);
                }
            });
            // 给合同计租日期设置初始值为今天
            $("#contract-rent-date").val(bDate);    // 日期工具类格式化日期
            // 初始化合同结束日期
            laydate.render({
                elem: '#contract-finish-date',
                btns: ['now'],   // 只显示今天按钮
                done: function (value, date, endDate) {
                    operate.changeDate('finish', value);
                }
            });
            // 给合同结束日期设置初始值为今天
            $("#contract-finish-date").val(cDate);    // 日期工具类格式化日期
        },
        // 初始化所属行业信息
        initIndustry: function () {
            $.ajax({
                url: "/dictionary/findByCode",
                data: {code: "PRO_007"},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        var data = res.data;
                        if (!!data) {
                            for (var i = 0; i < data.length; i++) {
                                var str = '<option value="' + data[i].ID + '">' + data[i].NAME + '</option>';
                                $("select[name='industry']").append(str);
                            }
                        }
                        form.render("select");
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        //初始化操作记录
        initrecord: function () {
            data = {};
            data.CONTRACT_ID = LOAN_ID;
            //加载 新建的业务 合同
            table.render({
                elem: '#historySH'
                , url: '/recordController/list'
                , where: data
                , cols: [[
                    {field: 'DETAILS', event: 'setSign', title: '操作详情', width:400,templet: '#DETAILS'}
                    , {field: 'OPERATOR', event: 'setSign', title: '操作人', width: 150}
                    , {field: '', event: 'setSign', title: '附件', width: 150,templet: '#record_img'}
                    , {field: 'OPERA_TIME', event: 'setSign', title: '操作时间', width: 150}

                ]]
                , id: ''
                , page: true
                , height: 'auto'
                , limit: '10'
                , size: 'sm' //小尺寸的表格
            });
        }
    };
    //操作方法
    var operate = {
        //删除附件
        deleteImg: function (obj, id) {
            $(obj).parent().parent().remove();
            console.log(uploadfiles)
            for (var i = 0; i < uploadfiles.length; i++) {
                if (uploadfiles[i].ID == id) {
                    console.log(id)
                    uploadfiles.splice(i, 1);
                }
            }
            console.log(uploadfiles)
        },
        // 通过点击几年的按钮显示不同的递增率和折扣 type为几年，1/3/5
        showDiscount: function (type) {
            $("#contract-finish-date").val(DateUtils.getNextNYearDate($("#contract-rent-date").val(), type));
            operate.appendDiscountSet(type);
            change.change();
        },
        // 通过改变日期显示不同的递增率和折扣 type为改变的哪个时间，date为时间
        changeDate: function (type, date) {
            var sDate = $("#contract-rent-date").val();
            var eDate = $("#contract-finish-date").val();
            if (type === 'start') {
                sDate = date;
            } else if (type === 'finish') {
                eDate = date;
            }
            var years = DateUtils.getYearsDiff(sDate, eDate);
            operate.appendDiscountSet(years);
            change.change();
        },
        // 克隆方法
        clone: function (obj) {
            var a = $(obj).parent().parent().find(".clone-box:last");
            var index = $(a).attr("data-index");
            var b = a.clone(true);
            $(b).attr("data-index", parseInt(index) + 1);
            $(b).find(".fa-plus-circle").hide();
            $(b).find(".fa-times-circle").show();

            $(b).find("textarea[name='room']").val("");
            $(b).find("textarea[name='room']").attr("data-id", "");
            $(b).find(".box-container dd").removeClass("layui-this");
            $(b).find(".building-box-container").empty();
            $(b).find(".building-box-container").hide();
            $(b).find(".unit-box-container").empty();
            $(b).find(".unit-box-container").hide();
            $(b).find(".floor-box-container").empty();
            $(b).find(".floor-box-container").hide();
            $(b).find(".room-box-container").empty();
            $(b).find(".room-box-container").hide();

            $(b).find(".room-area-single").empty();
            $(b).find(".room-area").hide();

            $(obj).parent().parent().append(b);
            form.render("select");
            $("input[name='securityDepositMoney']").val(calculate.securityDeposit().toFixed(2));
        },
        // 克隆押金类型方法
        cloneBondType: function (obj) {
            var str = '<div class="layui-inline">\n' +
                '          <div class="layui-input-inline layui-input-short">\n' +
                '              <input type="text" name="securityDepositName" placeholder="押金名称" lay-verify=""\n' +
                '                     autocomplete="off" class="layui-input">\n' +
                '          </div>\n' +
                '          <div class="layui-input-inline layui-input-longer">\n' +
                '              <input type="number" name="securityDepositPrice" lay-verify=""\n' +
                '                     autocomplete="off" class="layui-input">\n' +
                '              <span class="input-label-unit">元</span>\n' +
                '          </div>\n' +
                '          <i class="fa fa-times-circle" onclick="operate.remove(this, 1);" aria-hidden="true"></i>\n' +
                '      </div>';
            $(".bond-list").append(str);
        },
        // 增加联系人
        addContactPerson: function (obj) {
            var str = '<div class="contact-person-box">\n' +
                '          <div class="layui-inline">\n' +
                '              <label class="layui-form-label">联系人</label>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="text" name="lxr-name" lay-verify="required" autocomplete="off" class="layui-input">\n' +
                '              </div>\n' +
                '              <div class="layui-form-mid-red">*</div>\n' +
                '          </div>\n' +
                '          <div class="layui-inline">\n' +
                '              <label class="layui-form-label">联系电话</label>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="tel" name="lxr-tel" lay-verify="required" autocomplete="off" class="layui-input">\n' +
                '              </div>\n' +
                '              <div class="layui-form-mid-red">*</div>\n' +
                '              <i class="fa fa-times-circle" aria-hidden="true" onclick="operate.remove(this, 2);"></i>\n' +
                '          </div>\n' +
                '      </div>';
            $(obj).parent().parent().find(".contact-person-arr").append(str);
        },
        // 移除当前信息的方法，tier为几层父级
        remove: function (obj, tier) {
            switch (tier) {
                case 1:
                    $(obj).parent().remove();
                    break;
                case 2:
                    $(obj).parent().parent().remove();
                    break;
                case 3:
                    $(obj).parent().parent().remove();
                    break;
            }
        },
        // 通过年数生成该显示多少年的设置(实际)
        appendDiscountSet: function (years) {
            // 当前租金
            var unitPrice = $("input[name='rentSinglePrice']").val();
            if (!unitPrice) {
                unitPrice = 0;
            }

            init.initInputChange();
            // change.rentOrdiscountOrIncreasingChange();
        },
        // 新增租金明细
        createRentDetail: function () {
            var flag = true;    // each()中return只跳出循环，加标志位跳出方法
            /* 验证合同信息是否填全 */
            var loan_price = $("input[name='loan_price']").val();//借款金额
            var payment_reminder_day = $("input[name='payment_reminder_day']").val();
            var prePayDays = $("input[name='prePayDays']").val();//付息日期
            var borrow_Interest_Rate = $("input[name='borrow_Interest_Rate']").val();//借款利率
            // var late_payment_rate = $("input[name='late_payment_rate']").val();//滞纳金比率
            var remaining_price = $("input[name='remaining_price']").val();//剩余本金
            var late_pay_date = $("input[name='late_pay_date']").val();//滞纳金执行日
            if (!loan_price || !payment_reminder_day || !prePayDays || !borrow_Interest_Rate || !remaining_price || !late_pay_date) {
                layer.alert('合同信息未填写完全', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                return false;
            }

            /* 验证合同时间是否正确 */
            var sDate = $("#contract-rent-date").val();
            var eDate = $("#contract-finish-date").val();
            var compare = DateUtils.compareTime(sDate, eDate);
            if (compare !== -1) {
                layer.alert('合同结束时间必须大于开始时间', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                return false;
            }


            /* 将提示的状态改为true */
            tips = true;

            // 将暂无数据隐藏
            $(".quote-rent-detail-list").find(".no-data-tips").remove();

            $(".edit-rent-detail-btn").show();
            $(".edit-rent-detail-btngroup").hide();

            // 生成租金详情
            // 根据单位来 0 - 4
            change.createRentDetailTable();

            /* 显示修改明细的按钮 */
            $(".edit-rent-detail-btn").fadeIn(300);

            $(".layui-btn-disabled").removeClass("layui-btn-disabled");

        },
        // 修改租金明细
        editRentDetail: function () {
            layer.confirm('点击编辑，表单数据不再和基础数据联动，提交数据以表单为准', {
                btn: ['确认', '取消'] //按钮
            }, function (index) {

                $(".rent-detail-item-mzq").each(function () {
                    $(this).remove();
                });

                $(".container-rent-detail-list").find(".rent-detail-item").each(function (index, elem) {
                    if ($(this).hasClass("rent-detail-item-yj")) {
                        var name = $(this).find("div").eq(0).find("span").html();
                        var pDate = $(this).find("div").eq(1).find("span").html();
                        var zzje = $(this).find("div").eq(6).find("span.real-zjje").html();
                        var beizhu = $(this).find("div").eq(7).find("span").html();
                        var fkfpType = $(this).find("div").eq(6).find("span.fkfp-span").data("type");
                        var kfp = $(this).find("div").eq(6).find("span.fkfp-kfp").html();
                        var bkfp = $(this).find("div").eq(6).find("span.fkfp-bkfp").html();
                        var kfpJe = $(this).find("div").eq(6).find("span.fkfp-kfp-je").html();

                    } else {
                        var year = $(this).data("year");
                        var jcdj = $("input[name='rentSinglePrice']").val();
                        /* if (year != 1) {
                             jcdj = $(".contract-setting-discount").find(".contract-discount-body").eq(year - 2).find(".after-discount-money").html();
                         }*/
                        var sDate = $(this).find("div").eq(0).find("span").html().substring(0, 10);
                        var eDate = $(this).find("div").eq(0).find("span").html().substring(13, 23);
                        var pDate = $(this).find("div").eq(1).find("span").html();
                        var znj = 0;
                        if ($(this).find("div").eq(2).find("span").html() != undefined) {
                            znj = $(this).find("div").eq(2).find("span").html();
                        }
                        var zzje = $(this).find("div").eq(3).find("span").html();//最终金额
                        var beizhu = $(this).find("div").eq(4).find("span").html();


                        var str = '<li class="rent-detail-item" data-year="' + year + '" data-jcdj="' + jcdj + '">\n' +
                            '          <div>\n';

                        if (index != $(".container-rent-detail-list").find(".rent-detail-item").length - 1) {
                            str += '              <i onclick="operate.addRentItem(this);" class="fa fa-plus item-add" aria-hidden="true"></i>\n';
                        }

                        str += '              <div class="layui-input-inline">\n';
                        str += '                  <input type="text" data-value="' + sDate + '" value="' + sDate + '" class="layui-input layui-date startDate">\n' +
                            '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n';
                        str += '              </div>\n' +
                            '              -\n' +
                            '              <div class="layui-input-inline">\n';
                        str += '                  <input type="text" data-value="' + eDate + '" value="' + eDate + '" class="layui-input layui-date endDate">\n' +
                            '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n';
                        str += '              </div>\n' +
                            '          </div>\n' +
                            '          <div>\n' +
                            '              <div class="layui-input-inline">\n' +
                            '                  <input type="text" value="' + pDate + '" class="layui-input layui-date payDate">\n' +
                            '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n' +
                            '              </div>\n' +
                            '          </div>\n' +
                            '          <div>\n' +
                            '              <div class="layui-input-inline">\n' +
                            '                  <input type="number" name="edit-znj" value="' + znj + '" autocomplete="off" class="layui-input">\n' +
                            '              </div>\n' +
                            '          </div>\n';
                        str += '          <div>\n' +
                            '              <div class="layui-input-inline">\n' +
                            '                  <input type="number" oninput="" name="edit-zzje" value="' + zzje + '" autocomplete="off" class="layui-input">\n' +
                            '              </div>\n' +
                            '          </div>\n' +
                            '          <div class="discounts-select">\n';
                        if (index < $(".container-rent-detail-list").find(".rent-detail-item").length - 1) {
                            str += '              <i onclick="operate.remove(this, 3);" class="fa fa-times" aria-hidden="true"></i>\n';
                        }
                        str += `          </div>
                                  </li>`;
                        if ($(this).find("div").eq(2).find("span").html() != undefined && $(this).find("div").eq(3).find("span").html() != undefined) {
                            $(".container-rent-detail-list").append(str);
                        }
                    }
                    // 将编辑的租金详情隐藏
                    $(this).remove();
                });
                $(".layui-date").each(function () {
                    laydate.render({
                        elem: this,
                        btns: ['now']   // 只显示今天按钮
                    });
                });
                form.render("select");
                // change.editInputChange();
                layer.close(index);
                $(".edit-rent-detail-btn").hide();
                $(".edit-rent-detail-btngroup").show();
            });
        },
        // 增加租金明细单条
        addRentItem: function (obj) {
            var year = $(obj).parent().parent().data("year");
            var jcdj = $(obj).parent().parent().data("jcdj");
            var date = $(obj).parent().parent().find(".endDate").val();
            var fpzb = $("input[name='unit-fkfp']").val();
            var str = '<li class="rent-detail-item" data-year="' + year + '" data-jcdj="' + jcdj + '">\n' +
                '          <div>\n' +
                '              <i onclick="operate.addRentItem(this);" class="fa fa-plus item-add" aria-hidden="true"></i>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="text" data-value="" value="' + date + '" class="layui-input layui-date startDate">\n' +
                '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n' +
                '              </div>\n' +
                '              -\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="text" data-value="" value="' + date + '" class="layui-input layui-date endDate">\n' +
                '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n' +
                '              </div>\n' +
                '          </div>\n' +
                '          <div>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="text" value="' + date + '" class="layui-input layui-date payDate">\n' +
                '                  <span class="input-label-unit-icon"><i class="fa fa-calendar" aria-hidden="true"></i></span>\n' +
                '              </div>\n' +
                '          </div>\n' +
                '          <div>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="number" name="edit-znj" value="0" autocomplete="off" class="layui-input">\n' +
                '              </div>\n' +
                '          </div>\n' +
                '          <div>\n' +
                '              <div class="layui-input-inline">\n' +
                '                  <input type="number" oninput="change.editInputChange(this, 2);" name="edit-zzje" value="0" autocomplete="off" class="layui-input">\n' +
                '              </div>\n' +
                '          </div>\n' +
                '          <div class="discounts-select">\n' +
                '              <i onclick="operate.remove(this, 3);" class="fa fa-times" aria-hidden="true"></i>\n' +
                '          </div>\n' +
                '      </li>';
            $(obj).parent().parent().after(str);
            $(".layui-date").each(function () {
                laydate.render({
                    elem: this,
                    btns: ['now']   // 只显示今天按钮
                });
            });
            form.render('select');
        },
        // 取消修改租金明细
        cancelEditRentDetail: function () {
            layer.confirm('是否放弃手动修改所填的数据，重新生成账单？', {
                btn: ['确认', '取消'] //按钮
            }, function (index) {
                // 生成租金详情
                change.createRentDetailTable();
                layer.close(index);
                $(".edit-rent-detail-btngroup").hide();
                $(".edit-rent-detail-btn").show();
            });
        },
        // 保存修改的租金明细
        saveEditRentDetail: function () {
            // 生成租金详情
            layer.confirm('是否保存所修改的数据？', {
                btn: ['确认', '取消'] //按钮
            }, function (index) {
                // 保存生成租金详情
                change.saveRentDetailTable();
                layer.close(index);
                $(".edit-rent-detail-btngroup").hide();
                $(".edit-rent-detail-btn").show();
            });
        },
        // 取消新建合同
        cancel: function () {
            // 当你在iframe页面关闭自身时
            var index = parent.layer.getFrameIndex(window.name); // 先得到当前iframe层的索引
            parent.layer.close(index); // 再执行关闭

        },
        // 提交合同前验证
        validate: function () {
            var zlf = $("input[name='TRNANTRY']:checked").val();    // 租赁方
            var flag = true;

            if (zlf == 0) {
                /*var gsm = $("select[name='COMPANY']").val();    // 公司名
                if (!gsm) {
                    layer.alert('公司名不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                    return false;
                }*/
            } else if (zlf == 1) {
                var xm = $("input[name='NAME']").val();    // 姓名
                if (!xm) {
                    layer.alert('姓名不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                    return false;
                }
                var sfz = $("input[name='ID_CARD']").val();    // 身份证号
                if (!sfz) {
                    layer.alert('身份证号不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                    return false;
                }
            }

            var sshy = $("select[name='industry']").val();    // 所属行业
            if (!sshy) {
                layer.alert('所属行业不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                return false;
            }


            var lxdh = $("input[name='SIGN_TEL']").val();    // 联系电话
            /*if (!lxdh) {
                layer.alert('联系电话不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                return false;
            }*/

            $("input[name='lxr-tel']").each(function () {
                if (!$(this).val()) {
                    layer.alert('联系人电话不能为空', {title: ' ', btnAlign: 'c', icon: 0, resize: false});
                    flag = false;
                    return false;
                }
            });

            if (!flag) {
                return false;
            }

            return true;

        },
        // 变更合同
        changeContract: function (obj) {
            operate.submit(obj, 2);
        },
        // 提交当期合同
        submit: function (obj, submitType) {
            if (!$(obj).hasClass("layui-btn-disabled")) {

                if (submitType == 0) {
                    var flag = operate.validate();
                    if (!flag) {
                        return false;
                    }
                }

                // 联系人数组
                var contacts = new Array();
                $(".contact-person-box").each(function () {
                    var contact = {};
                    contact.CONTACTS_NAME = $(this).find("input[name='lxr-name']").val();
                    contact.CONTACTS_TEL = $(this).find("input[name='lxr-tel']").val();
                    contacts.push(contact);
                });

                var contractNum = $("input[name='CONTRACT_NUM']").val();
                var lease = $("input[name='TRNANTRY']:checked").val();
                var company = $("select[name='COMPANY']").val();
                var PERSON_ID = $("input[name='PERSON_ID']").val();
                var name = $("input[name='NAME']").val();
                var byname = $("input[name='byname']").val();
                var industry = $("select[name='industry']").val();
                var buss_code = $("input[name='BUSS_CODE']").val();
                var id_card = $("input[name='ID_CARD']").val();
                var leg_name = $("input[name='LEG_REN']").val();
                var leg_tel = $("input[name='LEG_TEL']").val();
                var COMPANY_TYPE=$("select[name='COMPANY_TYPE']").val();//公司类型
                var REG_CAPITAL=$("input[name='REG_CAPITAL']").val();
                var REG_CAPITAL_PAY=$("input[name='REG_CAPITAL_PAY']").val();
                var ESTABLISH_DATE=$("input[name='ESTABLISH_DATE']").val();//成立日期
                var REG_ADDRESS=$("textarea[name='REG_ADDRESS']").val();//注册地址
                var BUSINESS_ADDRESS=$("textarea[name='BUSINESS_ADDRESS']").val();//经营地址

                var address = $("textarea[name='ADDRESS']").val();
                var sign_ren = $("input[name='SIGN_REN']").val();
                var sign_tel = $("input[name='SIGN_TEL']").val();
                var LOAN_PRICE = $("input[name='LOAN_PRICE']").val();//借款金额
                var BORROW_INTEREST_RATE = $("input[name='BORROW_INTEREST_RATE']").val();//借款利率
                var BORROW_PERIOD = $("input[name='BORROW_PERIOD']").val();//借款期限
                var LATE_PAYMENT_RATE = $("input[name='LATE_PAYMENT_RATE']").val();//滞纳金比率
                var info = $("textarea[name='remark']").val();
                var con_date = $("#contract-signing-date").val();
                var con_hr_date = $("#contract-rent-date").val();
                var con_end_date = $("#contract-finish-date").val();
                var state = '0';
                var DY_CHECK = $("input[name='DY_CHECK']").val();
                var DY_CHECK_NAME = $("input[name='DY_CHECK_NAME']").val();


                var fkfp = $("input[name='fkfp']:checked").val();

                var late_fee = $("input[name='unit-znj']").val();

                // 租户基本信息
                var tenant = {};
                if (lease == 0) {
                    tenant.COMPANY_NAME = company;
                    tenant.BUSINESS_LICENSE = buss_code;
                } else if (lease == 1) {
                    tenant.COMPANY_NAME = name;
                    tenant.BUSINESS_LICENSE = id_card;
                }
                tenant.INDUSTRY_ID = industry;
                tenant.LEGAL_PERSON_NAME = leg_name;
                tenant.LEGAL_PERSON_TEL = leg_tel;
                tenant.CONTRACT_ADDRESS = address;
                tenant.BYNAME = byname;
                tenant.PERSON_ID = PERSON_ID;
                tenant.COMPANY_TYPE=COMPANY_TYPE;
                tenant.REG_CAPITAL=REG_CAPITAL;
                tenant.REG_CAPITAL_PAY=REG_CAPITAL_PAY;
                tenant.ESTABLISH_DATE=ESTABLISH_DATE;
                tenant.REG_ADDRESS=REG_ADDRESS;
                tenant.BUSINESS_ADDRESS=BUSINESS_ADDRESS;

                // 合同基本信息
                var contract = {};
                if(!!LOAN_ID){
                    contract.ID=LOAN_ID;
                }
                contract.CONTRACT_NUM = contractNum;
                contract.TRNANTRY = lease;
                contract.SIGNER = sign_ren;
                contract.SIGNER_TEL = sign_tel;
                contract.INFO = info;
                contract.LATE_FEE = late_fee;
                contract.CON_DATE = con_date;
                contract.CON_HR_DATE = con_hr_date;
                contract.CON_END_DATE = con_end_date;
                contract.FKFP_TYPE = fkfp;
                contract.STATE = state;
                contract.LOAN_PRICE = LOAN_PRICE;
                contract.BORROW_INTEREST_RATE = BORROW_INTEREST_RATE;
                contract.BORROW_PERIOD = BORROW_PERIOD;
                contract.LATE_PAYMENT_RATE = LATE_PAYMENT_RATE;//滞纳金利率
                contract.DY_CHECK = DY_CHECK;//动态审核标志
                contract.DY_CHECK_NAME = DY_CHECK_NAME;//动态审核人

                // 合同基本信息
                var tb_loan_company = {};
                tb_loan_company.HYYJ = $("select[name='HYYJ']").val();
                tb_loan_company.SHZTPJ=$("select[name='SHZTPJ']").val();
                tb_loan_company.SWPJ=$("select[name='SWPJ']").val();
                tb_loan_company.QYFX=$("select[name='QYFX']").val();
                tb_loan_company.QYZT=$("input[name='QYZT']:checked").val();
                tb_loan_company.QSQK=$("input[name='QSQK']:checked").val();
                tb_loan_company.QJSB=$("input[name='QJSB']:checked").val();
                tb_loan_company.XZCFJL=$("input[name='XZCFJL']:checked").val();
                tb_loan_company.FYSSXX=$("input[name='FYSSXX']:checked").val();
                tb_loan_company.FYQZZX=$("input[name='FYQZZX']:checked").val();
                tb_loan_company.DWDB=$("input[name='DWDB']:checked").val();
                tb_loan_company.DWDBBL=$("input[name='DWDBBL']:checked").val();
                tb_loan_company.YQDK=$("input[name='YQDK']:checked").val();
                tb_loan_company.THYQDK=$("input[name='THYQDK']:checked").val();
                tb_loan_company.DYWQSQX=$("input[name='DYWQSQX']:checked").val();
                tb_loan_company.GLQYBL=$("input[name='GLQYBL']:checked").val();

                var data = {};
                data.CONTACTS =  JSON.stringify(contacts);
                data.TENANT = JSON.stringify(tenant);
                data.CONTRACT = JSON.stringify(contract);
                data.DETAILS = $("textarea[name='DETAILS']").val();
                data.VISIT_CUSTOMER = $('input:radio[name="VISIT_CUSTOMER"]:checked').val();
                data.ID = LOAN_ID;
                data.CHECK_STATE = CHECK_STATE;
                data.ATTACHMENT = JSON.stringify(uploadfiles);
                data.loan_company = JSON.stringify(tb_loan_company);//借款企业信息
                if (submitType == 0) {
                    data.CHECK = 0;
                    layer.msg('确认通过吗', {
                        time: 0
                        , btn: ['确定', '取消']
                        , shade: 0.3
                        , yes: function (index) {
                            layer.close(index); // 关闭当前提示框
                            var i = parent.layer.getFrameIndex(window.name);
                            //合规阶段 特殊处理
                            if ("合规阶段"===CHECK_STATE){
                                parent.layer.open({
                                    type: 2,    //弹出类型
                                    title: '生成合同',   //标题
                                    closeBtn: 1,    //显示关闭按钮
                                    shade: [0.3],   //遮罩透明度
                                    area: ['1000px', '90%'],  //打开窗口的宽高
                                    time: 0,    //几秒后自动关闭，默认0时不关闭
                                    anim: 1,    //动画效果
                                    resize: false,  //设置成不允许拉伸
                                    content: '../../../webhtml/loan/loan_add.html?LOAN_ID=' + LOAN_ID+"&HGtype=HGtype"  //iframe的url
                                });
                                $(this).blur(); //移除焦点，防止点击回车按钮造成多次打开
                            }else {
                                $.ajax({
                                    url: "/LoanController/checkloan",
                                    data: data,
                                    dataType: "json",
                                    type: "post",
                                    async: false,
                                    success: function (res) {
                                        if (res.errcode === "0") {
                                            parent.layer.close(i);  // 关闭新建合同页面
                                            parent.layer.msg("审核成功");   // 父页面弹出保存成功
                                            // window.parent.location.reloadCONID();
                                            /*if(!!parent.frames[1].reloadCONID()){
                                                parent.frames[1].reloadCONID();
                                            }*/
                                            //如果是合规阶段 通过 打开 生成的合同页面
                                        } else if (res.errcode === "1") {
                                            layer.msg("保存失败");
                                            /*layer.msg(res.errmsg, function () {
                                            });*/
                                        }
                                    },
                                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                                        layer.msg("保存失败");
                                        console.error(XMLHttpRequest.status);
                                        console.error(XMLHttpRequest.readyState);
                                        console.error(textStatus);
                                    }
                                });
                            }
                        }
                    });
                } else if (submitType == 1) {
                    data.CHECK = 2;
                    layer.msg('确认驳回吗', {
                        time: 0
                        , btn: ['确定', '取消']
                        , shade: 0.3
                        , yes: function (index) {
                            layer.close(index); // 关闭当前提示框
                            var i = parent.layer.getFrameIndex(window.name);
                            // layer.alert(JSON.stringify(data));
                            $.ajax({
                                url: "/LoanController/checkloan",
                                data: data,
                                dataType: "json",
                                type: "post",
                                async: false,
                                success: function (res) {
                                    if (res.errcode === "0") {
                                        parent.layer.close(i);  // 关闭新建合同页面
                                        parent.layer.msg("审核成功");   // 父页面弹出保存成功
                                        if (!!$(parent.window.document).find("#htIframe")[0]) {
                                            $(parent.window.document).find("#htIframe")[0].contentWindow.reloadshenheID()
                                        }
                                    } else if (res.errcode === "1") {
                                        layer.msg("保存失败");
                                        /*layer.msg(res.errmsg, function () {
                                        });*/
                                    }
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    layer.msg("保存失败");
                                    console.error(XMLHttpRequest.status);
                                    console.error(XMLHttpRequest.readyState);
                                    console.error(textStatus);
                                }
                            });
                        }
                    });
                } else if (submitType == 2) {

                }
            }
            return false;
        }
    };
    //改变方法
    var change = {
        // 有输入值改变
        change: function (obj) {
            // 如果状态为true的话显示小提示
            if (tips === true) {
                $(".quote-rent-detail").find(".quote-title").find(".layui-layer-content").fadeIn(200);
            }
            // 只有当data-type是unit-div里的输入框值改变的时候才去调用重新计算的方法
            if ($(obj).parent().parent().attr("data-type") === "unit-div") {
                change.rentOrdiscountOrIncreasingChange($(obj));
            }
            if ($(obj).attr("name") === "unit-discount") {
                change.rentOrdiscountOrIncreasingChange($(obj));
            }
        },
        // 生成租金详情
        createRentDetailTable: function () {
            $(".container-rent-detail-list .rent-detail-item-mzq").each(function () {
                $(this).remove();
            });
            $(".container-rent-detail-list .rent-detail-item").each(function () {
                $(this).remove();
            });
            var sDate = $("#contract-rent-date").val();
            var eDate = $("#contract-finish-date").val();
            var allDays = DateUtils.dateDiffInClude(sDate, eDate);
            var years = DateUtils.getYearsDiff(eDate, sDate);
            var startDate = sDate;
            var endDate = eDate;
            var prePayDay = parseInt($("input[name='prePayDays']").val());//付息日
            var repayment = parseInt($("select[name='repayment']").val());//还款方式
            if (repayment == 1) {//按月付息

            }
            var payDateType = $("select[name='fxrq']").val();//付款提醒日 0 固定 1 提前
            if (ftype != 0) {
                // 月
                var months = Math.ceil(DateUtils.getSpacingMonths(sDate, eDate) / parseInt(repayment));//按月付息

                if (parseInt(eDate.substring(8, 10)) >= parseInt(sDate.substring(8, 10))) {
                    months++;
                }
                for (var i = 0; i < months; i++) {
                    var payDate;//付款日
                    if (payDateType == 1) {
                        // 头一条租金按计租日收费 ——————————按照固定日收费
                        // payDate = $("#contract-rent-date").val();
                        startDate = DateUtils.dateFormat(new Date(DateUtils.addDay(1, new Date(endDate))), "yyyy-MM-dd");
                        payDate = DateUtils.addDay(0 - prePayDay, new Date(startDate));
                    } else if (payDateType == 0) {//固定日收费 此处但是保留

                        prePayDay = parseInt($("input[name='prePayDays']").val());
                        if (prePayDay < 10) {
                            prePayDay = "0" + prePayDay;
                        }
                        //计租日期 计算  第一个计租日期
                        payDate = startDate.substring(0, 7) + "-" + prePayDay;
                        if (i > 0) {
                            startDate = DateUtils.dateFormat(new Date(DateUtils.addDay(1, new Date(endDate))), "yyyy-MM-dd");
                            var y = startDate.substring(0, 4);
                            var m = startDate.substring(5, 7);
                            var d = DateUtils.getDaysOfMonth(y, m);
                            if (prePayDay > d) {
                                prePayDay = d;
                            }
                            payDate = startDate.substring(0, 7) + "-" + prePayDay;
                        }
                    }
                    endDate = DateUtils.dateFormat(new Date(DateUtils.addDay(-1, new Date(DateUtils.addMoth(startDate, parseInt(repayment))))), "yyyy-MM-dd");
                    if (i === months - 1) {
                        endDate = eDate;
                    }

                    var zzje = $("input[name='loan_price']").val();  //最终金额
                    var yearCount = DateUtils.getYearsDiff(startDate, sDate);
                    var borrow_Interest_Rate = $("input[name='borrow_Interest_Rate']").val();//借款利率
                    zzje = parseInt(borrow_Interest_Rate / 100 * zzje);
                    var dateDiff = DateUtils.dateDiffInClude(startDate, endDate);
                    // 计算账单最终 金额 单位是0
                    // zzje = Number(zjdj) * parseInt(ftype);
                    zzje = zzje.toFixed(2);
                    var znj = 0;//滞纳金  借款金额的 千分之5
                    var remaining_price = parseInt($("input[name='remaining_price']").val());//滞纳金比率

                    var znj = (parseFloat($("input[name='loan_price']").val()) * remaining_price / 1000).toFixed(2);
                    if (!znj) {
                        znj = 0;
                    }
                    var dzl = 0;
                    var zk = 0;
                    var str = '<li class="rent-detail-item" data-year="' + yearCount + '">\n' +
                        '          <div>\n' +
                        '              <span>' + startDate + ' - ' + endDate + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + payDate + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + znj + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + zzje + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + '' + '</span>\n' +
                        '          </div>\n' +
                        '      </li>';
                    if (zzje != "NaN" && zzje != undefined && zzje != null && zzje != "") {
                        $(".container-rent-detail-list").append(str);
                    }

                }
                //最后一次 归还所有本金
                startDate = $("#contract-rent-date").val();//归还本本机的开始时间 合同开始时间
                endDate = $("#contract-finish-date").val();//归还本本机的开始时间     合同结束时间
                payDate = $("#contract-finish-date").val();//归还本本机的开始时间    应付款时间
                zzje = parseFloat($("input[name='loan_price']").val()).toFixed(2);//归还的最后金额
                var str = '<li class="rent-detail-item" data-year="' + yearCount + '">\n' +
                    '          <div>\n' +
                    '              <span>' + startDate + ' - ' + endDate + '</span>\n' +
                    '          </div>\n' +
                    '          <div>\n' +
                    '              <span>' + payDate + '</span>\n' +
                    '          </div>\n' +
                    '          <div>\n' +
                    '              <span>' + znj + '</span>\n' +
                    '          </div>\n' +
                    '          <div>\n' +
                    '              <span>' + zzje + '</span>\n' +
                    '          </div>\n' +
                    '          <div>\n' +
                    '              <span>' + '' + '</span>\n' +
                    '          </div>\n' +
                    '      </li>';
                if (zzje != "NaN" && zzje != undefined && zzje != null && zzje != "") {
                    $(".container-rent-detail-list").append(str);
                }
            }
        },
        // 固定日日期输入验证
        prePayDaysChange: function (obj) {
            if ($("select[name='fkrq']").val() == 1) {
                if ($(obj).val() < 1 || $(obj).val() > 30) {
                    $(obj).val("");
                    layer.msg("固定日期不能小于1或大于30", function () {
                    });
                }
            }
        },
        // 保存修改后的账单
        saveRentDetailTable: function () {

            var bs = $("#before-unable-date-start").val();
            var be = $("#before-unable-date-end").html();
            var as = $("#after-unable-date-start").html();
            var ae = $("#after-unable-date-end").val();

            $(".container-rent-detail-list").find(".rent-detail-item").each(function (index, elem) {

                var je = $(this).find("input[name='edit-zzje']").val();
                var fkfpStr = '';
                var fpblNum = $(this).find("input[name='unit-fkfp-num']").val();


                if ($(this).hasClass("rent-detail-item-yj")) {

                } else {
                    var yearCount = $(this).data("year");
                    var startDate = "";
                    startDate = $(this).find(".startDate").val();
                    var endDate = "";
                    endDate = $(this).find(".endDate").val();
                    var payDate = $(this).find(".payDate").val();
                    var znj = $(this).find("input[name='edit-znj']").val();
                    if (!znj) {
                        dzl = 0;
                    }
                    var zzje = $(this).find("input[name='edit-zzje']").val();
                    var beizhu = $(this).find("input[name='edit-beizhu']").val();

                    var str = '<li class="rent-detail-item" data-year="' + yearCount + '">\n' +
                        '          <div>\n' +
                        '              <span>' + startDate + ' - ' + endDate + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + payDate + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + znj + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + zzje + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + '' + '</span>\n' +
                        '          </div>\n' +
                        '      </li>';
                    $(this).remove();
                    $(".container-rent-detail-list").append(str);
                }
            });
        },
    };

    //打开新增合同的页面-其他信息录入
    function toContractQtAdd() {
        parent.layer.open({
            type: 2,    //弹出类型
            title: '新增其他信息',   //标题
            closeBtn: 1,    //显示关闭按钮
            shade: [0.3],   //遮罩透明度
            area: ['1000px', '90%'],  //打开窗口的宽高
            time: 0,    //几秒后自动关闭，默认0时不关闭
            anim: 1,    //动画效果
            resize: false,  //设置成不允许拉伸
            content: '../../../webhtml/loan/loan_qt_add.html?UUID='+LOAN_ID +'&isShowType=show'  //iframe的url
        });
        //   $(this).blur(); //移除焦点，防止点击回车按钮造成多次打开
    }

    function  radioType(value){
        if(value==1){

            $(".class_select_company").hide();
            $(".class_input_company").show();
        }else{

            $(".class_select_company").show();
            $(".class_input_company").hide();
        }

    }

    function  isShowCompany(company){
        debugger
        if(company!=null && company!="" && typeof(company)!="undefined" ){
            var sendData={};
            sendData.COMPANY_NAME=company;
            $.ajax({
                url: "/financial/findBorrower",
                data: sendData,
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {

                    if (res.errcode === "0") {

                        utils.setFormData("#contractForm_id",res.data);
                        form.render();
                    } else if (res.errcode === "1") {
                        layer.msg("查询失败");

                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg("查询失败");
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });

        }

    }
</script>
</body>
</html>